import table from '@/components/dt/table/render.js'
import nameOpt from '@/biz/option/name.js'
import dateOpt from '@/biz/option/date.js'
import Opt from '@/components/dt/info/Opt.js'
import dt from '@dt/dt'

let _this = null;

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [{
      title: '序号',
      field: 'name',
      width: 100,
      align: 'center',
      slots: {
        default: (params, h) => {
          return params._rowIndex - 0 + 1
        }
      },
    }, {
      title: '银行名称',
      field: 'AllbankName',
      minWidth: 180,
      align: 'center',
    }, {
      title: '状态',
      field: 'bankStatus',
      width: 120,
      align: 'center',
      slots: {
        default: (params, h) => {
          return params.row.bankStatus == '1' ? '启用' : '禁用'
        },
      }
    }, {
      title: '操作',
      fixed: 'right',
      width: 140,
      align: 'center',
      cell: (item) => {
        let btn = []
        btn.push({
          title: '编辑',
          event: 'changeBank',
          code: '0102010502'
        })
        if (item.bankStatus == 1) {
          btn.push({
            title: '禁用',
            event: 'changeStatus',
            code: '0102010504'
          })
        } else if (item.bankStatus == 2) {
          btn.push({
            title: '开启',
            event: 'changeStatus',
            code: '0102010504'
          })
        }
        btn.push({
          title: '删除',
          event: 'delChannel',
          code: '0102010503'
        })
        return {
          btn
        }
      }
      // slots: {
      //   default: (params, h) => {
      //     let btns = []
      //     btns.push({
      //       title: _this.unlocking('0102010502') ? '编辑' : '',
      //       event: 'addOrChangeBank',
      //       data: params.row
      //     })
      //     btns.push({
      //       title: _this.unlocking('0102010503') ? '删除' : '',
      //       event: 'delChannel',
      //       data: params.row
      //     })
      //     return table.cell.btns(_this, h, btns)
      //   }
      // }
    }, ]
  }
}


export default Column